<?php

namespace Pw\MainBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;
use Pw\MainBundle\Form\Type\TalentRarityType;
use Pw\MainBundle\Entity\TalentRarity;
class AdminCRUDController extends Controller
{
	public function addRarityAction(){
		$rarity = new TalentRarity();
		$form = $this->createForm(new TalentRarityType(), $rarity);
		$request = $this->getRequest();
		if ($request->isMethod('POST')) {
			$form->bind($request);
			if ($form->isValid()) {
				$em = $this->getDoctrine()->getManager();
				$em->persist($rarity);
				$em->flush();
				return $this->redirect($this->generateUrl('home'));
			}
		}
		return $this->render('PwMainBundle:AdminCRUD:addRarity.html.php',  array('form' => $form->createView()));		
	}
}
